<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.14"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>BabyOS: flexible_button.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="2.png"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">BabyOS
   &#160;<span id="projectnumber">V1.1.0</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.14 -->
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',false,false,'search.php','Search');
});
/* @license-end */</script>
<div id="main-nav"></div>
<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_b9223522bb56aee4ab59f7ba381d2163.html">bos</a></li><li class="navelem"><a class="el" href="dir_f2a2cc749b6bfcea90db6730434b0bd6.html">core</a></li><li class="navelem"><a class="el" href="dir_b26c46f3bf739d2a8c5275d4191a2f3f.html">thirdparty</a></li><li class="navelem"><a class="el" href="dir_4850241186a53d64f1c1cf7149add485.html">FlexibleButton</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">flexible_button.h</div>  </div>
</div><!--header-->
<div class="contents">
<a href="flexible__button_8h.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;</div><div class="line"><a name="l00031"></a><span class="lineno">   31</span>&#160;<span class="preprocessor">#ifndef __FLEXIBLE_BUTTON_H__</span></div><div class="line"><a name="l00032"></a><span class="lineno">   32</span>&#160;<span class="preprocessor">#define __FLEXIBLE_BUTTON_H__</span></div><div class="line"><a name="l00033"></a><span class="lineno">   33</span>&#160;</div><div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="b__config_8h.html">b_config.h</a>&quot;</span></div><div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;</div><div class="line"><a name="l00036"></a><span class="lineno">   36</span>&#160;<span class="preprocessor">#if _FLEXIBLEBUTTON_ENABLE</span></div><div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160;</div><div class="line"><a name="l00038"></a><span class="lineno">   38</span>&#160;<span class="preprocessor">#define FLEX_MS_TO_SCAN_CNT(ms) (ms / (1000 / FLEX_BTN_SCAN_FREQ_HZ))</span></div><div class="line"><a name="l00039"></a><span class="lineno">   39</span>&#160;</div><div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;<span class="comment">/* Multiple clicks interval, default 300ms */</span></div><div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;<span class="preprocessor">#define MAX_MULTIPLE_CLICKS_INTERVAL (FLEX_MS_TO_SCAN_CNT(300))</span></div><div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160;</div><div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;<span class="keyword">typedef</span> void (*flex_button_response_callback)(<span class="keywordtype">void</span>*);</div><div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160;</div><div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160;<span class="keyword">typedef</span> <span class="keyword">enum</span></div><div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160;{</div><div class="line"><a name="l00047"></a><span class="lineno">   47</span>&#160;    FLEX_BTN_PRESS_DOWN = 0,</div><div class="line"><a name="l00048"></a><span class="lineno">   48</span>&#160;    FLEX_BTN_PRESS_CLICK,</div><div class="line"><a name="l00049"></a><span class="lineno">   49</span>&#160;    FLEX_BTN_PRESS_DOUBLE_CLICK,</div><div class="line"><a name="l00050"></a><span class="lineno">   50</span>&#160;    FLEX_BTN_PRESS_REPEAT_CLICK,</div><div class="line"><a name="l00051"></a><span class="lineno">   51</span>&#160;    FLEX_BTN_PRESS_SHORT_START,</div><div class="line"><a name="l00052"></a><span class="lineno">   52</span>&#160;    FLEX_BTN_PRESS_SHORT_UP,</div><div class="line"><a name="l00053"></a><span class="lineno">   53</span>&#160;    FLEX_BTN_PRESS_LONG_START,</div><div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160;    FLEX_BTN_PRESS_LONG_UP,</div><div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160;    FLEX_BTN_PRESS_LONG_HOLD,</div><div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160;    FLEX_BTN_PRESS_LONG_HOLD_UP,</div><div class="line"><a name="l00057"></a><span class="lineno">   57</span>&#160;    FLEX_BTN_PRESS_MAX,</div><div class="line"><a name="l00058"></a><span class="lineno">   58</span>&#160;    FLEX_BTN_PRESS_NONE,</div><div class="line"><a name="l00059"></a><span class="lineno">   59</span>&#160;} flex_button_event_t;</div><div class="line"><a name="l00060"></a><span class="lineno">   60</span>&#160;</div><div class="line"><a name="l00123"></a><span class="lineno">  123</span>&#160;<span class="keyword">typedef</span> <span class="keyword">struct </span>flex_button</div><div class="line"><a name="l00124"></a><span class="lineno">  124</span>&#160;{</div><div class="line"><a name="l00125"></a><span class="lineno">  125</span>&#160;    <span class="keyword">struct </span>flex_button* next;</div><div class="line"><a name="l00126"></a><span class="lineno">  126</span>&#160;</div><div class="line"><a name="l00127"></a><span class="lineno">  127</span>&#160;    uint8_t  (*usr_button_read)(<span class="keywordtype">void</span> *);</div><div class="line"><a name="l00128"></a><span class="lineno">  128</span>&#160;    flex_button_response_callback  cb;</div><div class="line"><a name="l00129"></a><span class="lineno">  129</span>&#160;</div><div class="line"><a name="l00130"></a><span class="lineno">  130</span>&#160;    uint16_t scan_cnt;</div><div class="line"><a name="l00131"></a><span class="lineno">  131</span>&#160;    uint16_t click_cnt;</div><div class="line"><a name="l00132"></a><span class="lineno">  132</span>&#160;    uint16_t max_multiple_clicks_interval;</div><div class="line"><a name="l00133"></a><span class="lineno">  133</span>&#160;</div><div class="line"><a name="l00134"></a><span class="lineno">  134</span>&#160;    uint16_t debounce_tick;</div><div class="line"><a name="l00135"></a><span class="lineno">  135</span>&#160;    uint16_t short_press_start_tick;</div><div class="line"><a name="l00136"></a><span class="lineno">  136</span>&#160;    uint16_t long_press_start_tick;</div><div class="line"><a name="l00137"></a><span class="lineno">  137</span>&#160;    uint16_t long_hold_start_tick;</div><div class="line"><a name="l00138"></a><span class="lineno">  138</span>&#160;</div><div class="line"><a name="l00139"></a><span class="lineno">  139</span>&#160;    uint8_t id;</div><div class="line"><a name="l00140"></a><span class="lineno">  140</span>&#160;    uint8_t pressed_logic_level : 1;</div><div class="line"><a name="l00141"></a><span class="lineno">  141</span>&#160;    uint8_t event               : 4;</div><div class="line"><a name="l00142"></a><span class="lineno">  142</span>&#160;    uint8_t status              : 3;</div><div class="line"><a name="l00143"></a><span class="lineno">  143</span>&#160;} flex_button_t;</div><div class="line"><a name="l00144"></a><span class="lineno">  144</span>&#160;</div><div class="line"><a name="l00145"></a><span class="lineno">  145</span>&#160;<span class="preprocessor">#ifdef __cplusplus</span></div><div class="line"><a name="l00146"></a><span class="lineno">  146</span>&#160;<span class="keyword">extern</span> <span class="stringliteral">&quot;C&quot;</span> {</div><div class="line"><a name="l00147"></a><span class="lineno">  147</span>&#160;<span class="preprocessor">#endif</span></div><div class="line"><a name="l00148"></a><span class="lineno">  148</span>&#160;</div><div class="line"><a name="l00149"></a><span class="lineno">  149</span>&#160;int32_t flex_button_register(flex_button_t *button);</div><div class="line"><a name="l00150"></a><span class="lineno">  150</span>&#160;flex_button_event_t flex_button_event_read(flex_button_t* button);</div><div class="line"><a name="l00151"></a><span class="lineno">  151</span>&#160;uint8_t flex_button_scan(<span class="keywordtype">void</span>);</div><div class="line"><a name="l00152"></a><span class="lineno">  152</span>&#160;</div><div class="line"><a name="l00153"></a><span class="lineno">  153</span>&#160;<span class="preprocessor">#ifdef __cplusplus</span></div><div class="line"><a name="l00154"></a><span class="lineno">  154</span>&#160;}</div><div class="line"><a name="l00155"></a><span class="lineno">  155</span>&#160;<span class="preprocessor">#endif  </span></div><div class="line"><a name="l00156"></a><span class="lineno">  156</span>&#160;</div><div class="line"><a name="l00157"></a><span class="lineno">  157</span>&#160;<span class="preprocessor">#endif</span></div><div class="line"><a name="l00158"></a><span class="lineno">  158</span>&#160;</div><div class="line"><a name="l00159"></a><span class="lineno">  159</span>&#160;<span class="preprocessor">#endif </span><span class="comment">/* __FLEXIBLE_BUTTON_H__ */</span><span class="preprocessor"></span></div><div class="ttc" id="b__config_8h_html"><div class="ttname"><a href="b__config_8h.html">b_config.h</a></div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.14
</small></address>
</body>
</html>
